<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@page import="javax.naming.InitialContext"%>
<%@page import="java.util.Collection"%>
<%@page import="org.crud4j.core.CrudField"%>
<%@page import="org.crud4j.core.CrudService"%>
<%@page import="org.crud4j.core.CrudBrowsePage"%>
<%@page import="org.crud4j.portlet.CrudContextKey"%>
<fmt:setBundle basename="labels"/>
<%
	CrudField field = (CrudField) request.getAttribute("field");
	CrudService service = (CrudService) request
			.getAttribute(CrudContextKey.CRUD_SERVICE.getKey());
	CrudBrowsePage crudPage = service.browse(field.getDef().getType(),
			new Integer(Integer.MAX_VALUE), new Integer(0));
	Collection fks = crudPage.getBeans();
	request.setAttribute("fks", fks);
%>
<select name="<c:out value="${field.def.name}"/>">
<c:if test="${field.def.nullable}">
	<option	value=""><fmt:message key="label.none"/></option>
</c:if>
	<c:forEach var="fk" items="${fks}">
		<option
			value=<c:forEach var="fkid" items="${fk.ids}">"<c:out value="${fkid.value}"/>"
		<c:if test="${fkid.value eq field.value}"> selected="true"</c:if></c:forEach>>
		<c:out value="${fk.label}" /></option>
	</c:forEach>
</select>
